﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using Billing.Controls;
using Billing.Utilities;
using System.Configuration;

namespace Billing
{
    public partial class OldCakePrinter : Form
    {
        PaperSize psize;
        string cakeNo;
        string bookedDate;
        string deliveryDate;
        string customerName;
        string phoneNo;
        string shapeName;
        string albumModelDesc;
        string description;
        string message;
        string flavourSelected;
        string quantity;
        string extraAmount;
        string totalAmount;
        string advanceGiven;
        string balancePending;
        string discount;
        bool isChefCopy;
        string photo;
        string billNo;

        public OldCakePrinter(string cakeno, string bookedDt, string deliverydate, string customername, string phoneno, string shape, 
            string albummodeldesc, string desc, string msg, string flavour, string qty, string extra, string amount, string advance, string balance, string disc, bool ischefcopy, string photo, string billNo)
        {
            InitializeComponent();
            this.cakeNo = cakeno;
            this.bookedDate = bookedDt;
            this.deliveryDate = deliverydate;
            this.customerName = customername;
            this.phoneNo = phoneno;
            this.shapeName = shape;
            this.albumModelDesc = albummodeldesc;
            this.description = desc;
            this.message = msg;
            this.flavourSelected = flavour;
            this.quantity = qty;
            this.extraAmount = extra;
            this.totalAmount = amount;
            this.advanceGiven = advance;
            this.balancePending = balance;
            this.discount = disc;
            this.isChefCopy = ischefcopy;
            this.photo = photo;
            this.billNo = billNo;
        }

        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            int cnt = 0;
            int increment = 25;

            e.PageSettings.PaperSize = psize;
            e.Graphics.DrawString("KS BAKERS", new Font(new FontFamily("Times New Roman"), 13, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 140, cnt);
            cnt += increment;
            e.Graphics.DrawString(ConfigurationManager.AppSettings["ColonyName"], new Font(new FontFamily("Times New Roman"), 13, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 20, cnt);
            cnt += increment;
            e.Graphics.DrawString(ConfigurationManager.AppSettings["TinNo"], new Font(new FontFamily("Times New Roman"), 13, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 100, cnt);
            cnt += increment + 5;
            e.Graphics.DrawString("Cashier Name: " + Storage.LoginUser + "               Cake #: " + cakeNo.ToUpper(), new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, cnt);
            cnt += increment;
            e.Graphics.DrawString("Booked Date", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  " + bookedDate, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Delivery Date", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  " + deliveryDate, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Customer Name", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  " + customerName, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Phone No", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  " + phoneNo, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            if (shapeName != string.Empty)
            {
                if (isChefCopy)
                {
                    e.Graphics.DrawString("Shape", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 9, cnt);
                    e.Graphics.DrawString(":  " + shapeName, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 120, cnt);
                }
                else
                {
                    e.Graphics.DrawString("Shape", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                    e.Graphics.DrawString(":  " + shapeName, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
                }
            }
            else
            {
                if (isChefCopy)
                {
                    e.Graphics.DrawString("Album Model #", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 9, cnt);
                    e.Graphics.DrawString(":  " + albumModelDesc, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 120, cnt);
                }
                else
                {
                    e.Graphics.DrawString("Album Model #", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                    e.Graphics.DrawString(":  " + albumModelDesc, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
                }
            }
            cnt += increment;
            e.Graphics.DrawString("Desc:" + description, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 9, cnt);
            cnt += increment;
            e.Graphics.DrawString("Message", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  " + message, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            if (isChefCopy)
            {
                e.Graphics.DrawString("Flavour", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  " + flavourSelected, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 120, cnt);
            }
            else
            {
                e.Graphics.DrawString("Flavour", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  " + flavourSelected, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            }
            cnt += increment;
            if (isChefCopy)
            {
                e.Graphics.DrawString("Quantity", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  " + quantity + " Kg", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, 120, cnt);
            }
            else
            {
                e.Graphics.DrawString("Quantity", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  " + quantity + " Kg", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            }
            cnt += increment;
            if (extraAmount != string.Empty && extraAmount != "0")
            {
                e.Graphics.DrawString("Extra Amount", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  Rs " + extraAmount, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
                cnt += increment;
            }
            if (discount != string.Empty && discount != "0")
            {
                e.Graphics.DrawString("Discount Amount", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
                e.Graphics.DrawString(":  Rs " + discount, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
                cnt += increment;
            }

            e.Graphics.DrawString("Bill No", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(": " + billNo, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;

            e.Graphics.DrawString("Total Amount", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  Rs " + totalAmount, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Advance", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            //e.Graphics.DrawString(": ` " + advanceGiven, new Font(new FontFamily("Rupee Foradian"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 110, cnt);
            e.Graphics.DrawString(":  Rs " + advanceGiven, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Balance", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(":  Rs " + balancePending, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);
            cnt += increment;
            e.Graphics.DrawString("Photo Cake", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, cnt);
            e.Graphics.DrawString(": " + photo, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 120, cnt);

            cnt += increment + 10;
            if (!isChefCopy)
            {
                e.Graphics.DrawString("Please Bring Your Bill While Delivery", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 70, cnt);
                cnt += increment;
                e.Graphics.DrawString("Once ordered cannot be cancelled", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 90, cnt);
                cnt += increment;
                e.Graphics.DrawString("Thank You", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 155, cnt);
            }
            if (isChefCopy)
                e.Graphics.DrawString("CHEF COPY", new Font(new FontFamily("Times New Roman"), 45, System.Drawing.FontStyle.Regular), new SolidBrush(Color.FromArgb(64, Color.Black)), 10, 0);
        }

        private void printDocument1_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e)
        {
            psize = new PaperSize("saurabh", 400, 455);
            e.PageSettings.PaperSize = psize;
        }
    }
}
